[#include "/app/common/layout/__backstagemainlayout.html"/]
[#assign pageJavascript]
<script type="text/javascript">
$(function(){
	$(".checked").click(function(){
		$.ajax({
			type:"post",
			url:"${ContextPath}/admin/apartment/able",
			data:{
				"apartmentid":$(this).attr("apartmentid"),
			},
			success:function(msg){
				if(msg.state){
					alert("修改成功！");
				}else{
					alert("修改失败！");
				}
			},
			error:function(){
				alert("失败了！");
			}
		});
	});
	$("[data-toggle='popover']").popover({html : true });
});

$(document).ready(function() {
	$('.alert-you').mouseenter(function() {
		$(this).popover('show');
	});
	$('.alert-you').mouseleave(function() {
		$(this).popover('hide');
	});
});
</script>
[/#assign]
[@mainlayout pageJavascript=pageJavascript pageCss=pageCss currentMenu="organizationFlag-apartmentFlag-apartmentsListFlag"]

<div class="page-header">
	<h1>
		部门管理 
		<small> <i class="ace-icon fa fa-angle-double-right"></i> 部门列表</small>
	</h1>
</div>
<table class="table table-bordered table-hover">
		<thead>
			<tr>
				<th >编号</th>
				<th >单位名称</th>
				<th >父节点编号</th>
				<th >创建时间</th>
				<th >状态</th>
				<th >运维</th>
				<th >操作</th>
			</tr>
		</thead>
		<tbody>
			[#list apartmentTree as apartments]
			<tr>
				<td>${(apartments.id)!}</td>
				<td> ${(apartments.name)!}</td>
				<td>${(apartments.pid)!}</td>
				<td>${(apartments.created_at)!}</td>
				<td>
					<b>
					[#if apartments.deleted_at??]
					<span class="red">禁用</span>
					[#else]
					<span class="gray">正常</span>
					[/#if]
					</b>
				</td>
				<td>
					[#if apartments.flag="1"]
					<div class="alert-you" title="<b><span class='red'>提示</span></b>"  data-container="body" data-toggle="popover" data-placement="left" 
      							data-content="<b>取消后，该部门分配的故障处理选项将一起被取消！</b>">
					<input type="checkbox" class="ace ace-switch ace-switch-5 checked"  apartmentid="${(apartments.id)}"  checked />
					<span class="lbl middle"></span>
					</div>
					[#elseif apartments.flag="0"]
					<input type="checkbox" class="ace ace-switch ace-switch-5 checked"  apartmentid="${(apartments.id)}"   />
					<span class="lbl middle"></span>
					[/#if]
				</td>
				<td>
				<div class="action-buttons">
				<a class="btn btn-minier btn-primary btn-xs"  href="${ContextPath}/admin/apartment/edit?id=${(apartments.id)!}" >编辑</a>
				[#if apartments.deleted_at??]
				<a class="btn btn-minier btn-danger btn-xs"  href="${ContextPath}/admin/apartment/on?id=${(apartments.id)!}" >启用</a>
				[#else]
				<a class="btn btn-minier btn-primary btn-xs"  href="${ContextPath}/admin/apartment/off?id=${(apartments.id)!}" >禁用</a>
				[/#if]
				<a class="btn btn-minier btn-primary btn-xs"  href="${ContextPath}/admin/apartment/add?id=${(apartments.id)!}" >添加</a>
				</div>
				</td>
			</tr>
			[#list apartments.children as apartment]
				<tr>
				<td></td>
				<td><span class="glyphicon glyphicon-minus-sign"></span>&nbsp;&nbsp;${(apartment.name)!}</td>
				<td>${(apartment.pid)!}</td>
				<td>${(apartment.created_at)!}</td>
				<td>
					<b>
					[#if apartment.deleted_at??]
					<span class="red">禁用</span>
					[#else]
					<span class="gray">正常</span>
					[/#if]
					</b>
				</td>
				<td></td>
				<td>
				<div class="action-buttons">
				<a class="btn btn-minier btn-primary btn-xs"  href="${ContextPath}/admin/apartment/edit?id=${(apartment.id)!}" >编辑</a>
				[#if apartment.deleted_at??]
				<a class="btn btn-minier btn-danger btn-xs"  href="${ContextPath}/admin/apartment/on?id=${(apartment.id)!}" >启用</a>
				[#else]
				<a class="btn btn-minier btn-primary btn-xs"  href="${ContextPath}/admin/apartment/off?id=${(apartment.id)!}" >禁用</a>
				[/#if]
				</div>
				</td>
			</tr>
			[/#list]
			[/#list]
		</tbody>
	</table>
[/@mainlayout]